package coreservice

import (
	"core/coredto"
	"core/coreentity"
	"core/corestruct"
)

type htUserDeptService struct {
}

func (p htUserDeptService) GetUserDepts(uid int64, ctx *corestruct.HttpContext) (*[]coredto.HtDeptBaseDto, error) {
	var r *[]coredto.HtDeptBaseDto
	var tx = ctx.DB.Model(&coreentity.HtUserDept{}).
		Select("b.id,b.name,b.htplat_id,b.pid").
		Joins("join htdept b on HtUserDept.htuser_id=? and HtUserDept.State='启用' AND HtUserDept.htdept_id=b.id and b.deleted=0 ", uid).
		Find(&r)
	if tx.Error != nil {
		return nil, tx.Error
	}
	return r, nil
}

var (
	HtUserDeptService = &htUserDeptService{}
)
